
package com.benimetum.beans;

import com.benimetum.items.Course;
import com.benimetum.items.Student;
import com.benimetum.items.Teacher;
import com.benimetum.managers.LoginManager;
import com.benimetum.managers.TeacherManager;
import java.io.Serializable;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;

/**
 *
 * @author Ethem Cem Ozkan
 * @email ethemcem.ozkan@gmail.com
 * No 07110604
 */
@ManagedBean(name="TeacherBean")
@SessionScoped
public class TeacherBean implements Serializable
{
    private Teacher target;

    public Teacher getTarget() {
	  return target;
    }

    public void setTarget(Teacher target) {
	  this.target = target;
	  if(target.getStatus()==null)
		target.setStatus("Durum güncellemesi yok");
    }
    
    public boolean same(){
	  return target.getId().equals(LoginManager.getUser().getId());
    }
    
    public Course[] courses(){
	  return TeacherManager.getTeachersCourses(target.getId());
    }
    
    public String profilePicture(){
	  return target.getProfilePicture();
    }
    
    public void changeStatus(){
	  TeacherManager.updateTeacherStatus(target.getId(), target.getStatus());
    }
    
    public Student[] getMentored(){
        return TeacherManager.getMentorsStudents(target.getId());
    }
    
    public boolean checkTarget(){
	  return target!=null;
    }
}
